package jp.seraph.jspf.pose;

import org.apache.commons.lang.NullArgumentException;

import jp.seraph.jsade.core.Agent;
import jp.seraph.jsade.model.AngleVelocityCalculator;
import jp.seraph.jsade.model.DefaultAngleVelocityCalculator;
import jp.seraph.jsade.task.TaskSelector;
import jp.seraph.jsade.task.TaskSelectorAgent;

/**
 * セットされたポーズに自身を設定するAgent実装
 *
 */
public class PoseAgent extends TaskSelectorAgent implements Agent {
    public PoseAgent(){
        this(new NopPoseSelector());
    }

    public PoseAgent(TaskSelector aSelector) {
        this(aSelector, new DefaultAngleVelocityCalculator());
    }

    public PoseAgent(TaskSelector aSelector, AngleVelocityCalculator aDefaultCalculator) {
        super(aSelector);

        if(aDefaultCalculator == null)
            throw new NullArgumentException("aDefaultCalculator");


        mDefaultCalculator = aDefaultCalculator;
    }

    private AngleVelocityCalculator mDefaultCalculator;

    @Deprecated
    public void setPose(Pose aPose) {
        this.setPose(aPose, mDefaultCalculator);
    }

    @Deprecated
    public void setPose(Pose aPose, AngleVelocityCalculator aCalculator) {
        if(aPose == null)
            throw new NullArgumentException("aPose");
        if(aCalculator == null)
            throw new NullArgumentException("aCalculator");

        this.setPose(new DefaultPoseElement(aPose, aCalculator));
    }

    @Deprecated
    public void setPose(PoseElement... aElements) {
        PoseSet tPoseSet = new DefaultPoseSet();
        for (PoseElement tPoseElement : aElements) {
            tPoseSet.addElement(tPoseElement);
        }

        this.setPose(tPoseSet);
    }

    /**
     * このエージェントを、角速度計算機を指定して、対象のポーズに変更する。
     *
     * @param aPose
     */
    @Deprecated
    public void setPose(PoseSet aPose) {
        if(aPose == null)
            throw new NullArgumentException("aPose");

        this.setSelector(new MonoPoseSelector(aPose));
    }
}
